package org.mysterylab.utopiaframework.commons.compass.domain;

import java.io.Serializable;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableComponent;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

/**
 * 商品, 用来作为如图书, 健身器材等物品的超类.
 * 
 * @author zhouych
 * @see Category
 */
@SuppressWarnings("serial")
@Searchable(alias = "product")
public class Product implements Serializable {

	/**
	 * 主键ID
	 */
	@SearchableId
	private long id;
	
	/**
	 * 该产品的名称
	 */
	private String name;
	
	/**
	 * 库存容量
	 */
	private int inventory;
	
	/**
	 * 该产品所属的目录
	 */
	private Category category;
	
	/**
	 * 该产品的单价
	 */
	private double price;
	
	/**
	 * 该产品的折扣(默认没有折扣)
	 */
	private double discount = 1.0;
	
	/**
	 * 该产品的描述
	 */
	private String description;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	// 按照商品的名称来进行搜索
	@SearchableProperty(name = "productname")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	// 按照商品的类别名进行搜索(类别名为 "category")
	@SearchableComponent(refAlias = "category")
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public int getInventory() {
		return inventory;
	}

	public void setInventory(int inventory) {
		this.inventory = inventory;
	}

	// 按照价钱来进行搜索
	@SearchableProperty(name = "price")
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	// 按照折扣来进行搜索
	@SearchableProperty(name = "discount")
	public double getDiscount() {
		return discount;
	}

	// 按照商品的描述信息来进行搜索
	@SearchableProperty(name = "productdes")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
